<?php

class Core_Agent_Component_Customer_View_Shop_Create extends Core_Agent_Share_View_Form {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('customer/index/index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.submit'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(array('status'=>'draft'), 'save') . "')");
        $group->addButton($this->__('share.button.save'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(array('status'=>'pending'), 'save') . "')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('shop_form')
                ->addHiddenField('id', 'model[id]')
                ->addHiddenField('poi_id', 'model[poi_id]', $this->getPoi()->getId());
//        $form->addFileField($this->__('poi.label.signmap'), 'signmap', 'model[signmap]');
        $form->addTextboxField($this->__('share.label.tag'), 'tag', 'model[tag]');
//        $form->addTextboxField($this->__('customer.label.ebook_url'), 'ebook_url', 'model[ebook_url]');
        $form->addTextboxField($this->__('customer.label.url_name'), 'sef_url', 'model[sef_url]');
//        $form->addTextboxField($this->__('customer.label.location_id'), 'location_id', 'model[location_id]');
        $form->addFileField($this->__('poi.label.signmap_picture'), 'signmap_picture', 'model[signmap_picture]');
        $form->addTextareaField($this->__('share.label.introduction'), 'introduction', 'model[introduction]');
//        $form->addEditorField($this->__('share.label.detail'), 'detail', 'model[detail]');
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
            if($entity->issetData('signmap_picture')){
            	$form->getInput('signmap_picture')
            		->setBaseUrl($this->getRouter()->getBaseUrl().'pub/customer/shop/'.$entity->getId().'/');
            }
        }
        parent::buildForm($form);
    }

}